﻿<!DOCTYPE html>
<html lang="en">
<#include "../include/resource-head.ftl"/>
<#assign active='configList'/>
<body>
<#include "../include/common-top.ftl"/>
<div class="main-container" id="main-container">
    <div class="main-container-inner">
    <#include "../include/common-menu.ftl"/>
        <div class="main-content">
            <div class="page-content">
                <div class="col-xs-12">
                    <div class="row-fluid">
                        <div class="widget-box">
                            <div class="widget-header widget-header-blue widget-header-flat">
                                <h4 class="lighter">
                                    <i class="icon-plus"></i>添加商品
                                </h4>
                            </div>
                            <div class="widget-body">
                                <div class="widget-main">
                                    <div class="step-content row-fluid position-relative">
                                        <form class="form-horizontal" action="/goods/add" method="post"
                                              enctype="multipart/form-data">

                                            <div class="form-group has-goods">
                                                <label class="col-xs-12 col-sm-3 control-label no-padding-right">商品名</label>
                                                <div class="col-xs-12 col-sm-5">
                                                    <input type="text" class="width-100" required name="name"/>
                                                </div>
                                            </div>
                                            <div class="form-group has-goods">
                                                <label class="col-xs-12 col-sm-3 control-label no-padding-right">商品编号</label>
                                                <div class="col-xs-12 col-sm-5">
                                                    <input type="text" class="width-100" required name="no"/>
                                                </div>
                                            </div>
                                            <div class="form-group has-goods">
                                                <label class="col-xs-12 col-sm-3 control-label no-padding-right">类别</label>
                                                <div class="col-xs-12 col-sm-5">
                                                    <select  class="width-100" name="category">
                                                        <option value="家电">家电</option>
                                                        <option value="食品">食品</option>
                                                        <option value="日用百货">日用百货</option>
                                                        <option value="其他">其他</option>
                                                    </select>

                                                </div>
                                            </div>

                                            <div class="form-group has-goods">
                                                <label class="col-xs-12 col-sm-3 control-label no-padding-right">店铺</label>
                                                <div class="col-xs-12 col-sm-5">
                                                    <select name="shopid" class="width-100">
                                                        <#list shopList as item>
                                                            <option value="${item.id}">${item.name!}</option>
                                                        </#list>
                                                    </select>
                                                </div>
                                            </div>

                                            <div class="form-group has-goods">
                                                <label class="col-xs-12 col-sm-3 control-label no-padding-right">上传图片</label>
                                                <div class="col-xs-12 col-sm-5">
                                                    <input type="file" class="width-100" required name="file"/>
                                                </div>
                                            </div>

                                            <div class="form-group has-goods">
                                                <label class="col-xs-12 col-sm-3 control-label no-padding-right">进价</label>
                                                <div class="col-xs-12 col-sm-5">
                                                    <input type="number" class="width-100" required name="price"/>
                                                </div>
                                            </div>

                                            <div class="form-group has-goods">
                                                <label class="col-xs-12 col-sm-3 control-label no-padding-right">售价</label>
                                                <div class="col-xs-12 col-sm-5">
                                                    <input type="number" class="width-100" required name="money"/>
                                                </div>
                                            </div>
                                            <hr/>
                                            <div class="row-fluid wizard-actions">
                                                <button class="btn" type="reset">重置</button>
                                                <button class="btn btn-success" type="submit">提交</button>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div><!-- /.page-content -->
        </div><!-- /.main-content -->
    </div><!-- /.main-container -->
</body>
<#include "../include/resource-script.ftl"/>
<script>

    $("#ct").change(function () {
        change($("#ct").val(),"ct2");
    });

    $("#ct2").change(function () {
        change($("#ct2").val(),"ct3");
    });

    function change(pid,obj) {
        $.getJSON("/shop/getByPid",{pid:pid},function(result){
            var html = '';
            for(var i=0;i<result.length;i++){
                html +='<option value="'+result[i].id+'">'+result[i].name+'</option>';
            }

            $("#"+obj).html(html);
            if(obj === 'ct2'){
                $("#ct2").change();
            }

        })
    }
</script>
</html>

